<template>  
    <view class="container">  
		
		<view class="user-section">
			<!-- <image class="bg" src="/static/user-bg2.png"></image> -->
			<view class="user-info-box">
				<view class="portrait-box">
					<image class="portrait" :src="userInfo.avatar"></image>
				</view>
				<view class="info-box">
					<text class="username">{{userInfo.nick_name}}</text>
					<view style="color:rgba(255,255,255,0.7)" class="username-">
						{{userInfo.invite_code}}
					</view>
				</view>
				<view class="card-bao" v-if="userInfo.team_level">
					{{userInfo.team_level}}
				</view>
			</view>
			<view class="vip-card-box">
				
				<view style="display: flex;align-items: center;">
					<!-- <view class="yticon icon-iLinkapp-"></view> -->
					<view style="margin-left:9rpx;display: flex;align-items: center;">
						
						<view v-for="index in userInfo.level" :key="index" style="display: flex;align-items: center;margin-top:5rpx;">
							<image src="/static/level.png" style="width:40rpx;height:40rpx;" mode=""></image>
						</view>
					</view>
				</view>
				
				<view class="b-btn" v-if="userInfo.is_agent===true" @click="enterpage('../daili/index')">
					{{userInfo.agent}}
				</view>
				<view class="tit" v-else>
					
					{{userInfo.agent}}
				</view>
				
			</view>
		</view>
		
		<view 
			class="cover-container"
			:style="[{
				transform: coverTransform,
				transition: coverTransition
			}]"
			@touchstart="coverTouchstart"
			@touchmove="coverTouchmove"
			@touchend="coverTouchend"
		>
			<image class="arc" src="/static/arc.png"></image>
			
			<view class="tj-sction" style="border-bottom-left-radius: 0;border-bottom-right-radius: 0;">
				<view class="tj-item" @click="enterpage('../yuemingxi/index')">
					<text class="num">{{userInfo.balance}}</text>
					<text>余额</text>
					
				</view>
				<view class="tj-item" @click="enterpage('../chanpinquan/index')">
					<text class="num">{{userInfo.product_coupon}}</text>
					<text>产品券</text>
					
				</view>
				<view class="tj-item" @click="enterpage('../jifenquan/index')">
					<text class="num">{{userInfo.points_coupon}}</text>
					<text>积分券</text>
					
				</view>
				<!-- <view class="tj-item">
					<text class="num">{{userInfo.total_consumption}}</text>
					<text>消费总额</text>
				</view> -->
			</view>
			
			<!-- <view class="tj-sction" style="border-top-left-radius: 0;border-top-right-radius: 0;">
				<view class="tj-item" @click="enterpage('../chanpinlilv/index')">
					<text class="num">{{userInfo.profit}}</text>
					<text>产品利润</text>
					
				</view>
				<view class="tj-item" @click="enterpage('../gupiaoedu/index')">
					<text class="num">{{userInfo.stock}}</text>
					<text>增值券</text>
					
				</view>
				<view class="tj-item" @click="enterpage('../tuangouquan/index')">
					<text class="num">{{userInfo.coupon}}</text>
					<text>团购券</text>
					
				</view>
				<view class="tj-item" @click="enterpage('../daijinquan/index')">
					<text class="num">{{userInfo.vouchers}}</text>
					<text>代金券</text>
				</view>
			</view> -->
			
			<view class="order-section">
				<view class="order-item" @click="enterpage('../shopwrap/shoporder')" hover-class="common-hover"  :hover-stay-time="50">
					<view class="img-shouye">
						<image src="/static/zhongxindingdan.png" mode=""></image>
					</view>
					
					<view>
						我的订单
					</view>
				</view>
				<view class="order-item"  @click="enterpage('../lirunshouchu/index')"  hover-class="common-hover" :hover-stay-time="50">
					
					
					<view class="img-shouye">
						<image src="/static/zhongxinyue.png" mode=""></image>
					</view>
					
					<view>
						利润售出
					</view>
				</view>
				<view class="order-item" hover-class="common-hover"  @click="enterpage('../wodetuandui/index')"  :hover-stay-time="50">
					
					
					<view class="img-shouye">
						<image src="/static/zhongxintuiguang.png" mode=""></image>
					</view>
					
					<view>
						我的推广
					</view>
				</view>
				
				<view class="order-item"  @click="enterpage('../yaoqing/index')"  hover-class="common-hover" :hover-stay-time="50">
					
					
					<view class="img-shouye">
						<image src="/static/yaoqinghaoyou.png" mode=""></image>
					</view>
					
					<view>
						邀请好友
					</view>
				</view>
			</view>
			
			<view class="history-section icon">
				
				<list-cell icon="icon-erjiye-yucunkuan" iconColor="#5fcda2" title="代金券激活" @eventClick="enterpage('../daijinquanduihuan/index')"></list-cell>
				
				<list-cell v-if="userInfo.is_transfer" @eventClick="enterpage('../zichanhuzhuan/index')" icon="icon-iconfontweixin" iconColor="#e07472" title="资产互转"></list-cell>
				<list-cell icon="icon-fenlei1" iconColor="#5fcda2" title="股票签约" @eventClick="enterpage('../gupiaoqianyue/index')"></list-cell>
				<list-cell icon="icon-pinglun-copy" iconColor="#5fcda2" title="余额提现" @eventClick="enterpage('../bizhongtibi/index')"></list-cell>
				<list-cell icon="icon-dizhi" iconColor="#5fcda2" title="地址管理" @eventClick="enterpage('/pages/shopwrap/shopaddress')"></list-cell>
				<list-cell icon="icon-shouye" @eventClick="enterpage('../wodedianpu/index','dianpu')" iconColor="#9789f7" title="我的店铺"></list-cell>
				<list-cell icon="icon-pinglun-copy"  @eventClick="enterpage('../kefu/index')" iconColor="#ee883b" title="联系客服"></list-cell>
				<list-cell icon="icon-shezhi1" @eventClick="enterpage('/pages/anquanshezhi/index')" iconColor="#e07472" title="系统设置" border=""></list-cell>
			</view>
		</view>
			
		
    </view>  
</template>  
<script>  
	import listCell from '@/components/mix-list-cell';
    import {  
        mapState 
    } from 'vuex';  
	let startY = 0, moveY = 0, pageAtTop = true;
    export default {
		components: {
			listCell
		},
		data(){
			return {
				
				userInfo:{},
				coverTransform: 'translateY(0px)',
				coverTransition: '0s',
				moving: false,
			}
		},
		onShow() {
			this.getData()
		},
		onLoad(){
			
		},
		
		onNavigationBarButtonTap(e) {
			const index = e.index;
			if (index === 0) {
				this.enterpage('../anquanshezhi/index')
			}else if(index === 1){
				this.enterpage('../gonggaolist/index')
				
			}
		},
		
      
        methods: {
			enterpage(path,type){
				if(path){
					switch(type){
						case 1:
							uni.navigateTo({
								url: path+`?src=${this.dataObj.about_us}`
							});
						break;
						case 'dianpu':
						if(this.userInfo.is_shop){
							uni.navigateTo({
							    url: path
							});
						}else{
							uni.showToast({
							    title: '未加盟店铺',
							    duration:4000,
								icon:'none'
							});
						}
						break;
						default:
						uni.navigateTo({
						    url: path
						});
					}
				}else{
					uni.showToast({
					    title: '暂未开放',
					    duration:4000,
						icon:'none'
					});
				}
			},
			getData(){
				let that=this
				
				that.apipost('/api/user/index').then(res => {
					if(res.Code==10200){
						that.userInfo=res.Data
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			coverTouchstart(e){
				if(pageAtTop === false){
					return;
				}
				this.coverTransition = 'transform .1s linear';
				startY = e.touches[0].clientY;
			},
			coverTouchmove(e){
				moveY = e.touches[0].clientY;
				let moveDistance = moveY - startY;
				if(moveDistance < 0){
					this.moving = false;
					return;
				}
				this.moving = true;
				if(moveDistance >= 80 && moveDistance < 100){
					moveDistance = 80;
				}
		
				if(moveDistance > 0 && moveDistance <= 80){
					this.coverTransform = `translateY(${moveDistance}px)`;
				}
			},
			coverTouchend(){
				if(this.moving === false){
					return;
				}
				this.moving = false;
				this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
				this.coverTransform = 'translateY(0px)';
			}
        }  
    }  
</script>  
<style lang='scss'>
	.card-bao{
		position:fixed;
		right:0;
		top:186rpx;
		background: linear-gradient(to right, #f9e3a8, #f7d988);
		width:140rpx;
		height:44rpx;
		border-top-left-radius: 40rpx;
		border-bottom-left-radius: 40rpx;
		display:flex;
		justify-content: center;
		align-items: center;
	}
	%flex-center {
	 display:flex;
	 flex-direction: column;
	 justify-content: center;
	 align-items: center;
	}
	%section {
	  display:flex;
	  justify-content: space-around;
	  align-content: center;
	  background: #fff;
	  border-radius: 10rpx;
	}

	.user-section{
		height: 520rpx;
		padding: 80rpx 30rpx 0;
		position:relative;
		.bg{
			position:absolute;
			left: 0;
			top: 0;
			width: 100%;
			height: 100%;
			filter: blur(1px);
			/* opacity: .7; */
		}
	}
	.user-info-box{
		height: 180rpx;
		display:flex;
		align-items:center;
		position:relative;
		z-index: 1;
		.portrait{
			width: 130rpx;
			height: 130rpx;
			border:5rpx solid #fff;
			border-radius: 50%;
		}
		.username{
			font-size: 36rpx;
			margin-bottom:4rpx;
			margin-left: 20rpx;
		}
		.username-{
			margin-left:20rpx;
			font-size: 27rpx;
		}
	}

	.vip-card-box{
		display:flex;
		flex-direction: column;
		color: #f7d680;
		height: 240rpx;
		background: linear-gradient(to left, rgba(0,0,0,.6), rgba(0,0,0,.6));
		border-radius: 16rpx 16rpx 0 0;
		overflow: hidden;
		position: relative;
		padding: 20rpx 24rpx;
		.card-bg{
			position:absolute;
			top: 20rpx;
			right: 0;
			width: 380rpx;
			height: 260rpx;
		}
		.b-btn{
			position: absolute;
			right: 20rpx;
			top: 23rpx;
			width: 132rpx;
			height: 46rpx;
			display:flex;
			align-items: center;
			justify-content: center;
			 
			font-size: 22rpx;
			color: #36343c;
			border-radius: 20px;
			background: linear-gradient(to right, #f9e3a8, #f7d988);
			z-index: 1;
		}
		.tit{
			position: absolute;
			right: 20rpx;
			top: 23rpx;
			width: 132rpx;
			height: 46rpx;
			display:flex;
			align-items: center;
			justify-content: center;
			 
			font-size: 22rpx;
			color: #36343c;
			border-radius: 20px;
			background: linear-gradient(to right, #f9e3a8, #f7d988);
			z-index: 1;
		}
		.e-b{
			font-size: $font-sm;
			color: #d8cba9;
			margin-top: 10rpx;
		}
	}
	.cover-container{
		background: $page-color-base;
		margin-top: -220rpx;
		padding: 0 30rpx;
		position:relative;
		background: #f5f5f5;
		padding-bottom: 110rpx;
		.arc{
			position:absolute;
			left: 0;
			top: -34rpx;
			width: 100%;
			height: 36rpx;
		}
	}
	.tj-sction{
		@extend %section;
		.tj-item{
			@extend %flex-center;
			flex-direction: column;
			
			width:33.333%;
			word-break: break-all;
			font-size: 32rpx;
			color: #75787d;
			padding:10rpx 0;
		}
		.num{
			font-size: $font-lg;
			color: $font-color-dark;
			margin-bottom: 8rpx;
		}
	}
	.order-section{
		@extend %section;
		padding: 28rpx 0;
		margin-top: 20rpx;
		.order-item{
			@extend %flex-center;
			width: 120rpx;
			height: 120rpx;
			border-radius: 10rpx;
			font-size: 30rpx;
			color: $font-color-dark;
		}
		.yticon{
			font-size: 48rpx;
			margin-bottom: 18rpx;
			color: #fa436a;
		}
		.icon-shouhoutuikuan{
			font-size:44rpx;
		}
	}
	.history-section{
		
		margin-top: 20rpx;
		background: #fff;
		border-radius:10rpx;
		.sec-header{
			display:flex;
			align-items: center;
			font-size: $font-base;
			color: $font-color-dark;
			line-height: 40rpx;
			margin-left: 30rpx;
			.yticon{
				font-size: 44rpx;
				color: #5eba8f;
				margin-right: 16rpx;
				line-height: 40rpx;
			}
		}
		.h-list{
			white-space: nowrap;
			padding: 30rpx 30rpx 0;
			image{
				display:inline-block;
				width: 160rpx;
				height: 160rpx;
				margin-right: 20rpx;
				border-radius: 10rpx;
			}
		}
	}
	.img-shouye{
		width:40rpx;
		height:40rpx;
		margin-bottom:22rpx;
	}
	page{
		background:#f5f5f5;
	}
	
	.user-section{
		background:url(/static/user-bg2.png) no-repeat;
		background-size:100% auto;
		
	}
</style>